﻿package mortal.game.view.guild.otherpanel
{
    import Message.Game.*;
    import Message.Public.*;
    import com.gengine.utils.*;
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import flash.utils.*;
    import mortal.common.global.*;
    import mortal.component.gconst.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class GuildDonateGoldPanel extends GuildOtherBasePanel
    {
        private var _btnYes:GButton;
        private var _btnNo:GButton;
        private var _txtNum:MoneyInput;
        private static var _instance:GuildDonateGoldPanel;

        public function GuildDonateGoldPanel(param1:ILayer = null)
        {
            super(param1);
            setSize(235, 145);
            if (_instance)
            {
                throw new Error("单例");
            }
            title = "" + Language.getString(71157);
            return;
        }// end function

        override public function layoutUI() : void
        {
            super.layoutUI();
            this._txtNum = UIFactory.getUICompoment(MoneyInput, 70, 40, this);
            this._txtNum.unit = EPriceUnit._EPriceUnitGold;
            this._txtNum.defultText = GuildConst.ApplyGoldMinValue.toString();
            var _loc_1:* = Language.getStringByParam(71158, HTMLUtil.addColor(GuildConst.ApplyGoldMinValue.toString(), GlobalStyle.colorHuang));
            _loc_1 = HTMLUtil.addColor(_loc_1, GlobalStyle.colorLv);
            var _loc_2:* = UIFactory.textField("", 19, 70, 255, 44, this);
            _loc_2.htmlText = _loc_1;
            this._btnYes = UIFactory.gButton("" + Language.getString(71159), 45, 120, 65, 22, this);
            this._btnNo = UIFactory.gButton("" + Language.getString(71160), 135, 120, 65, 22, this);
            return;
        }// end function

        override public function onMouseClick(event:MouseEvent) : void
        {
            var _loc_2:Dictionary = null;
            var _loc_3:Object = null;
            super.onMouseClick(event);
            switch(event.target)
            {
                case this._btnYes:
                {
                    if (this._txtNum.value < GuildConst.ApplyGoldMinValue)
                    {
                        MsgManager.showRollTipsMsg("" + Language.getString(71161));
                        return;
                    }
                    if (this._txtNum.value > GameConst.TGuildWarehouseDonateMaxGold)
                    {
                        MsgManager.showRollTipsMsg("" + Language.getString(71162));
                        return;
                    }
                    _loc_2 = new Dictionary();
                    _loc_2[EPriceUnit._EPriceUnitGold] = this._txtNum.value;
                    _loc_3 = {};
                    _loc_3.oper = new EGuildWarehouseOper(EGuildWarehouseOper._EGuildWarehouseIn);
                    _loc_3.item = null;
                    _loc_3.oprMoney = _loc_2;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.Guild_wareHouse_oper, _loc_3));
                    this.hide();
                    break;
                }
                case this._btnNo:
                {
                    this.hide();
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        override public function update() : void
        {
            super.update();
            return;
        }// end function

        public static function get instance() : GuildDonateGoldPanel
        {
            if (_instance == null)
            {
                _instance = new GuildDonateGoldPanel;
            }
            return _instance;
        }// end function

        public static function hasInstance() : Boolean
        {
            return _instance != null;
        }// end function

    }
}
